var mongodb = require('mongodb');

module.exports = function(config) {
  return new Promise((resolve, reject) => {

    mongodb.MongoClient.connect(`mongodb://${config.host||'localhost'}:${config.port||27017}/${config.database||IMChat}`, function(err, db) {
      if (err) return reject(err);

      resolve(db);
    });
  });
};
